<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<link rel="stylesheet" href="css/external/codemirror.css" />
<script src="js/libs/code/codemirror.js"></script>

<div id="userTaskWizard" class="wizard box tabbedBox no-border">
	<div class="header">
		<ul class="steps">
			<li><a href="#nodeBasicInfo">常规</a>
			</li>
			<li><a href="#nodeUserInfo">人员设置</a>
			</li>
			<li><a href="#nodeEventInfo">任务脚本设定</a>
			</li>
			<li><a href="#nodeMessageInfo">消息设定</a>
			</li>
		</ul>
	</div>
	<div class="content tabbed" style="padding:0">

		<div id="nodeBasicInfo">
			<form:form id="bpmNodeSettingForm" commandName="model"
				cssClass="validate" action="bpm/nodeSetting/save">
				<form:hidden path="id" />
				<form:hidden path="bpmProcessSettingId" />
				<form:hidden path="actNodeId" />
				<table class="form-table">
					<tr>
						<td class="td1">步骤名称：</td>
						<td class="td2"><h3 class="">${name }</h3>
						</td>
					</tr>
					<tr>
						<td class="td1">表单：</td>
						<td class="td2"><form:input path="formUrl"
								cssStyle="width:85%" /></td>
					</tr>

					<tr>
						<td class="td1">处理权限：</td>
						<td class="td2"><form:checkbox path="canRollback" label="退回" />
						</td>
					</tr>
					<tr>
						<td class="td1">手机提交模式：</td>
						<td class="td2"><isperp:dictSelector id="mobileHandleType"
								codeValue="true" hasEmptyValue="none"
								selectedValue="${model.mobileHandleType }"
								name="mobileHandleType" typeCode="${defKey }_mobileHandleType"></isperp:dictSelector>
						</td>
					</tr>

					<tr>
						<td class="td1">提交方式：</td>
						<td class="td2"><form:radiobutton path="commitType" value="0"
								label="共享处理" /> <form:radiobutton path="commitType" value="1"
								label="确认唯一处理人" /> <form:radiobutton path="commitType"
								value="2" label="确定多个处理人" /></td>
					</tr>
					<tr>
						<td class="td1">是否弹出提交窗口：</td>
						<td class="td2"><form:checkbox path="areOpenCommentWindow"
								label="是" />（选择提交人，编写处理意见！）<br>

							注意：如果提交方式为“确认唯一处理人”，系统自动弹出提交窗口！</td>
					</tr>
					<tr>
						<td class="td1">处理后动作：</td>
						<td class="td2"><form:select path="areAutoEntryNext">
								<form:option value="0">关闭页面</form:option>
								<form:option value="1">直接进入下一步</form:option>

							</form:select>（注意：进入下一步后，如果当前处理人无处理权限则显示查看表单）
					</tr>


					<tr style="display: none">
						<td class="td1">默认跳转路径：</td>
						<td class="td2"><form:select path="defaultTran"
								items="${outLines }" itemLabel="name"
								itemValue="nextTransitionId"></form:select>
						</td>
					</tr>

				</table>
			</form:form>
		</div>
		<div id="nodeUserInfo">

			<isperp:grid url="bpm/nodeUser/list?bpmNodeSettingId=${model.id}"
				gridId="nodeUserGrid" cusFormatterActions="true"
				cusEditUrl="bpm/nodeUser/edit" cusDialogSize="normal"
				beforeCreateAction="'bpmNodeSettingId=${model.id}'" width="auto"
				autowidth="true" cusDeleteUrl="bpm/nodeUser/delete"
				showPager="false" showSearchbar="false"
				loadComplete="nodeUserGrid.jqGrid.setGridWidth($(window).width());"
				ondbClickRowEvent="nodeUserGrid.edit(rowid);">
				<jsp:attribute name="toolbar">
					<button onclick="javascript:nodeUserGrid.create();return false;"
						class="nui-mainbtn">添加流程人员</button>
				</jsp:attribute>
				<jsp:body>
					<isperp:column name="id" title="id" hidden="true"></isperp:column>
					<isperp:column name="assignType" title="处理人类型" width="180"
						isFormatterFun="true"
						formatter="switch(cellvalue){ 
						case 0:return '流程发起人';
						case 10:return '上一步提交人';
						case 1:return '特定角色';
						case 11:return '项目中的特定角色';
						case 111:return '项目中的全部人员';
						case 2:return '特定成员';
						case 3:return '表单内成员帐号';	
						case 31:return '表单内成员id';						
						case 4:return '特定部门下所有成员';
						case 5:return '任务处理人';
						case 6:return '特定已处理步骤下的处理人';
						
						
						case 20:return '客户用户的帐号';
						case 21:return '客户特定组织下的所有成员';
						case 22:return '表单内客户用户字段所属组织下的特定职务人员';
						case 23:return '表单内客户用户字段所属组织下的特定角色人员';
						case 24:return '表单内客户用户字段所属组织的系统特定角色人员';
						default:return cellvalue;
						 }">
					</isperp:column>
			        <isperp:column name="cmpNames" title="分配对象" width="360">
					</isperp:column>
				</jsp:body>
			</isperp:grid>
		</div>
		<div id="nodeEventInfo">
			<form:form id="bpmNodeEventForm" commandName="model"
				cssClass="validate" action="bpm/nodeSetting/save">
				<input type="hidden" name="id" value="${model.id }" />

				<table class="form-table">
					<tr>
						<td class="td1">任务开始脚本：</td>
						<td class="td2"><form:textarea path="startScriptContent"
								cssClass="mirroreditor" /> <isperp:processVariable
								id="startScriptContentVariable" targetControlId="mirroreditor"
								targetIsEditor="true" processKey="${defKey }"></isperp:processVariable>
							<isperp:operate code="WORKFLOW_DAO" title="数据访问实体dao使用说明"></isperp:operate>
						</td>

					</tr>
					<tr>
						<td class="td1 ">转派脚本：</td>
						<td class="td2"><form:textarea path="transferScriptContent"
								cssClass="mirroreditor" /></td>

					</tr>
					<tr>
						<td class="td1">节点完成：</td>
						<td class="td2"><form:textarea
								path="completeScriptContent" cssStyle="height: 110px" /></td>
					</tr>
					<!-- <tr>
						<td class="td1">节点分配人员：</td>
						<td class="td2" style="width:45%"><form:textarea
								path="assignScriptContent" cssStyle="height: 110px" />
						</td>
						<td class="td2" style="width:45%"><div style="padding:2px 0 ">
								<form:input path="assignMessageTitle" cssStyle="width:85%" />
							</div> <form:textarea path="assignMessage" cssStyle="height: 90px" />
						</td>
					</tr>
					<tr>
						<td class="td1">节点完成：</td>
						<td class="td2" style="width:45%"><form:textarea
								path="completeScriptContent" cssStyle="height: 110px" /></td>

						<td class="td2" style="width:45%"><div style="padding:2px 0 ">
								<form:input path="completeMessageTitle" cssStyle="width:85%" />
							</div> <form:textarea path="completeMessage" cssStyle="height: 90px" />
						</td>
					</tr> -->
				</table>
			</form:form>
		</div>

		<div id="nodeMessageInfo">
			<form:form id="bpmNodeMessaegForm" commandName="model"
				cssClass="validate" action="bpm/nodeSetting/save">
				<input type="hidden" name="id" value="${model.id }" />
				<form:hidden path="messageType" />
				<table class="form-table">
					<tr>
						<td class="td1">消息：</td>
						<td class="td2" style="padding:5px 0"><form:checkboxes
								items="${messageTypes }" path="messageTypes" />
							<div style="padding:5px 0">
								<form:input path="startMessageTitle" cssStyle="width:85%" />
							</div> <form:textarea path="startMessage" cssStyle="height: 240px" />
							<isperp:processVariable id="startMessageVariable"
								targetControlId="startMessage" processKey="${defKey }"></isperp:processVariable>
							<div>温馨提示：如果发送短信请控制字数在140字以内。</div>
						</td>
					</tr>
					<tr>
						<td class="td1">消息脚本(需要返回Map)：</td>
						<td class="td2" style="padding:5px 0"><form:textarea
								path="startMessageScript" cssClass="mirroreditor" /> <isperp:processVariable
								id="startMessageScriptVariable" useAsScript="true"
								targetControlId="startMessageScript" processKey="${defKey }"></isperp:processVariable>
							<isperp:operate code="WORKFLOW_DAO" title="数据访问实体dao使用说明"></isperp:operate>
						</td>
					</tr>
				</table>

			</form:form>
		</div>
	</div>
	<isperp:wizButtonList buttonListId="bpmConfigWizardBtns">
	</isperp:wizButtonList>

</div>
<script type="text/javascript">
	var wizCreate = isperp.wizard({
		wizardId : "userTaskWizard"
	});

	var mirroreditor = CodeMirror.fromTextArea(document.getElementById("startScriptContent"), {
		mode : "groovy",
		lineNumbers : true,
		tabMode : "indent"
	});
	mirroreditor.on("change", function() {
		clearTimeout(pending);
		setTimeout(updateMirroreditor, 100);
	});
	var pending;

	var updateMirroreditor = function() {
		mirroreditor.setOption("mode", "groovy");
	};

	var userTaskWizard_Event1 = function(index, obj) {
		isperp.submitForm({
			formId : "bpmNodeSettingForm",
			success : function() {
				return true;
			}
		});
	};

	var userTaskWizard_Event2 = function(index, obj) {
		window.setTimeout(updateMirroreditor, 100);
	};

	var userTaskWizard_Event3 = function(index, obj) {
		mirroreditor.save();

		isperp.submitForm({
			formId : "bpmNodeEventForm",
			success : function() {
				return true;
			}
		});
	};

	var userTaskWizard_Event4 = function(index, obj) {

		isperp.submitForm({
			formId : "bpmNodeMessaegForm",
			success : function() {
				isperp.closeDialog();
			}
		});
	};
</script>